The present invention relates to apparatuses that render graphic images in the field of computer graphics, and in particular to apparatuses that calculate the color of pixels constituting graphic images.
In recent years, as technology for game consoles and car navigation systems advances, graphic images are not only rendered in a single color, but the pixels constituting graphic images are subjected to various processes, such as performing texture mapping, gouraud shading, in which the colors between the vertices of the graphic image are interpolated, or alpha blending, in which a transparency process with the background color is performed.
Details concerning texture mapping and gouraud shading can be looked up in “Computer Graphics: Principles and Practice” by James D. Foley, Andries van Dam, Steven K. Feiner, and John F. Hughes, translated by Yoshio Sato.
FIG. 16 shows a conventional configuration for subjecting a graphic image to texture mapping and gouraud shading. Based on the X and Y coordinates, texture coordinates U and V, as well as R, G and B indicating the brightness given to the vertices of the graphic image that is to be rendered, a pixel information generation portion 1 generates U, V, as well as R, G and B for the X and Y coordinates of each pixel constituting the graphic image. It should be noted that R, G and B are taken to be in the range of 0.0 to 1.0.
Taking the triangular shape shown in FIG. 17 as an example, the following is an explanation of the process by which the pixel information generation portion 1 generates the value of each pixel constituting the graphic image. The triangle shown in FIG. 11 has been given (X, Y, U, V, R, G, B) at its vertices. At vertex P1, (X Y, U, V, R, G, B) is (X1, Y1, U1, V1, R1, G1, B1), at vertex P2, (X Y, U, V, R, G, B) is (X2, Y2, U2, V2, R2, G2, B2), and at vertex P3, (X, Y, U, V, R, G, B) is (X3, Y3, U3, V3, R3, G3, B3). Y2 and Y3 are assumed to be equal.
FIG. 18 illustrates the principle of the pixel information generation process. This process begins from the vertex P1 where the Y coordinate is smallest, and determines the X coordinates of the left side and the right side of the graphic image for each Y coordinate. In the course of this, also the values of U, V, R, G and B corresponding to the left side are determined. After the values of the left side of the currently processed Y coordinate have been determined, the X coordinates are incremented parallel to the X axis from the X coordinate of the left side to the X coordinate on the right side, while determining the corresponding U, V, R, G and B values. This process is performed up to Y2, which is the last Y coordinate, at which the process is terminated.
The following is a detailed explanation of the flow of the pixel information generation process, referring to the flowchart in FIG. 19. First, the parameters shown in that figure are defined as follows:dXL/dY=(X2−X1)/(Y2−Y1)dXR/dY=(X3−X1)/(Y2−Y1)dU/dY=(U2−U1)/(Y2−Y1)dU/dX=(U3−U2)/(X3−X2)dV/dY=(V2−V1)/(Y2−Y1)dV/dX=(V3−V2)/(X3−X2)dR/dY=(R2−R1)/(Y2−Y1)dR/dX=(R3−R2)/(X3−X2)dG/dY=(G2−G1)/(Y2−Y1)dG/dX=(G3−G2)/(X3−X2)dB/dY=(B2−B1)/(Y2−Y1)dB/dX=(B3−B2)/(X3−X2)
It should be noted that these parameters can be calculated internally in the pixel information generation portion 1, or they can be previously calculated externally and then given to the pixel information generation portion 1. Furthermore, XL, UL, VL, RL, GL and BL are variables for storing the values at the left edge, and are here referred to as “left edge variables.” XR is a variable for storing the X coordinate at the right edge, and is here referred to as “right edge variable.” Furthermore, X, Y, U, V, R, G and B are variables for storing the values of the pixels constituting the graphic image, and are here referred to as “pixel variables.” These values are output from the pixel information generation portion 1. The afore-mentioned variables can be stored in storage elements, such as registers in circuitry.
When the storage begins, at Step S1, the left edge variables and the pixel variables of the Y coordinate are respectively set to the values for the vertex P1, and the procedure advances to Step S2. At Step S2, the pixel variables are respectively set to the values stored in the left edge variables, and the procedure advances to Step S3. The values that are stored into the pixel variables at Step S2 are output from the pixel information generation portion 1 as the values of the pixels constituting the left edge of the graphic image.
At Step S3, if the pixel variable of the X coordinate is equal to the right edge variable, then the procedure advances to Step S5, and if it is not equal, then it advances to Step S4. At Step S4, the pixel variable of the X coordinate is incremented, and a displacement in X direction is respectively added to the pixel variables U, V, R, G and B, and then the procedure returns to Step S3. The values that are stored in the pixel variables at Step S4 are output from the pixel information generation portion 1 as the values of the pixels constituting the graphic image except for the left edge.
At Step S5, if the pixel variable of the Y coordinate is equal to the Y coordinate of the vertex P2, then the procedure is terminated, and if it is not equal, then the procedure advances to Step S6. At Step S6, the pixel variable of the Y coordinate is incremented, and a displacement in Y direction is respectively added to the left edge variables, and then the procedure returns to Step S2.
Thus, the pixel information generation portion 1 generates X, Y, U, V, R, G and B of each pixel constituting the graphic image.
In FIG. 16, a texture memory 2, which is the memory where the texture is stored, outputs texture data in correspondence with the U and V that are output from the pixel information generation portion 1. These texture data include R, G and B in each set of data.
A multiplier 3 multiplies the R, G and B output from the pixel information generation portion 1 respectively with the R, G and B of the texture data.
An adder 4 adds the R, G and B output from the multiplier 3 respectively to the R, G and B of a bias value, and outputs pixel data constituted by the R, G and B that determine the color of a pixel of the graphic image. If R, G or B after the addition exceed 1.0, then that value is saturated to 1.0.
The frame memory 5, which is the memory for rendering the graphic image, stores the pixel data constituted by R, G and B. The graphic image information built up in the frame memory 5 is displayed-on a display (not shown in the drawings).
A memory interface portion 6 writes into the frame memory 5 the pixel data at the locations corresponding to the X and Y coordinates that are output by the pixel information generation portion 1.
However, when trying to add alpha blending as a new function to a conventional configuration performing texture mapping and gouraud shading on a graphic image, the calculation(texture)×(R, G, B)+(bias value)which is necessary for gouraud shading, becomes(1−transparency)×(texture)+(transparency)×(background value)for alpha blending.
Thus, not only the calculation itself but also the variables that are input are different, so that in order to add an alpha blending function, a dedicated calculation circuit was necessary.
Providing a dedicated calculation circuit for each rendering function increases the scale of the circuitry, and there was the problem that the types of rendering functions could not be increased with circuitry of small scale.
It is thus an object of the present invention to solve these problems, and to provide a graphic image rendering apparatus that eliminates the need for dedicated circuitry for each function and that realizes multi-functional rendering with circuitry of a small scale.